const express = require('express');
const cors = require('cors');
const app = express();

app.use('/upload', express.static('./upload'));
app.use(cors());

// 连接数据库
const booksDatabase = require('./database/booksDatabase');

// // 创建表
// const Books = require('./model/booksModel');

// 同步数据库
booksDatabase.sync({ alter: true });

// 路由
const booksRouter = require('./router/booksRouter');

app.use('/', booksRouter);
require('dotenv').config();
app.listen(process.env.PORT, () => {
  console.log(`server  is running at port ${process.env.PORT}`);
});
